home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 2.3 KB | 122 lines | [TEXT/MSET] |
- \ 28Oct94 dbh updated to 2.5 syntax
-
- (*
-
- The concept behind the font class is to have a class that guarantees proper
- handling of the basic font attributes on the Macintosh. We make no
- assumptions about the font number, but rather store the font name and then obtain
- the font number via a toolbox call each time we run the program.
- We default to Monaco 9 plain text. Important, we must *always* do a getnew:
- before using the font. See class staticText for how to use.
-
-
- *)
-
-
-
- \ these could be konst's to save a little dictionary space
- 0 constant plain
- 1 constant bold
- 2 constant italic
- 4 constant underline
- 8 constant outline
- 16 constant shadow
- 32 constant condensed
- 64 constant extended
-
- :class font super{ object }
- \ must never set these directly
- record FontInfo {
- int ascent
- int descent
- int widMax
- int leading
- }
- int lineheight \ computed at getnew: time
-
- int font#
-
- \ user settable
- $16 name
- int fontsize
- int mode
- int style
-
- :m classinit:
- " Monaco" put: name
- 9 put: fontsize
- konst srcOr put: mode
- plain put: style
- ;m
-
- :m set: \ must only do after a getnew:
- get: font# tfont
- get: fontsize tsize
- get: style tface
- get: mode tmode ;m
-
- :m getnew:
- get: name str255 font# call GetFNum \ 28Oct94 dbh
- set: self
- FontInfo call GetFontInfo \ 28Oct94 dbh
- get: ascent
- get: descent +
- get: leading + put: lineheight
- ;m
-
- \ the following are only valid after a getnew:
- :m ascent: ( -- n)
- get: ascent ;m
-
- :m descent: ( -- n)
- get: descent ;m
-
- :m widMax: ( -- n)
- get: widMax ;m
-
- :m leading: ( -- n)
- get: leading ;m
-
- :m lineheight: ( -- n)
- get: lineheight ;m
-
- (* just for debugging
- :m dumpfont:
- cr ." ascent " ascent: self initfont .
- cr ." descent " descent: self initfont .
- cr ." widMax " widMax: self initfont .
- cr ." leading " leading: self initfont .
- cr ." lineheight " lineheight: self initfont .
- cr ." fontnumber " get: font# initfont .
- cr ." fontname " initfont print: name
- cr ." fontsize " get: fontsize initfont .
- cr ." style " get: style initfont .
- cr ." mode " get: mode initfont .
- ;m
- *)
-
- \ user settable, call anytime. But won't take effect without
- \ a subsequent getnew:
- :m fontName: ( addr len -- )
- put: name ;m
-
- :m fontSize: ( n -- )
- put: fontsize ;m
-
- :m mode: ( n -- )
- put: mode ;m
-
- :m style: ( n -- )
- put: style ;m
-
- ;class
-
- endload
-
- *** EXAMPLE USE
-
- See class staticText for how to use.
-
-
-
-